<html>
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="scripts/jquery.min.js"></script>
    <title>Title</title>
    <script>
        function check(frm) {
            console.log("frm")
            console.log(typeof frm)
            //所有的标签（html、xml）在js世界都是一个个对象
            var username = frm.acname.value;
            var password = frm.passwd.value;
            if (username == "" || password == "") {
                alert("账户或密码不能为空")
                return false;
            }
            return true;
        }
    </script>
</head>
<!--<body style="background-image: url('sourse/log.jpg');background-size: 100%">-->
<div class="container">
    <div class="row clearfix">
        <div class="col-md-12 column">
            <h3 id="ts" style="color:red"></h3>
            <form id="zc1" role="form" action="javascript:void(0)" >
                <div class="form-group">
                    <label for="username">账户名</label>
                    <input style="height: 25px;margin-left:10px;padding-left: 10px;" type="text" class="form-control"
                           id="username" name="username"
                           placeholder="请输入用户名"/>
                </div>
                <div class="form-group" style="margin-top: 30px;">
                    <label for="password">密&nbsp;&nbsp;&nbsp;码</label>
                    <input style="height: 25px;margin-left:10px;padding-left: 10px;" type="password"
                           class="form-control" id="password" name="password"/>
                </div>
                <div class="form-group" style="margin-top: 30px;">
                    <label for="password2">密&nbsp;&nbsp;&nbsp;码</label>
                    <input style="height: 25px;margin-left:10px;padding-left: 10px;"
                           type="password"
                           class="form-control" id="password2" name="password2"/>
                </div>
                <div class="form-group" style="margin-top: 30px;">
                    <label for="phone">电话</label>
                    <input style="height: 25px;margin-left:10px;padding-left: 10px;"
                           type="text"
                           class="form-control" id="phone" name="phone"/>
                </div>
                <div class="form-group" style="margin-top: 30px;">
                    <label for="email">邮箱</label>
                    <input style="height: 25px;margin-left:10px;padding-left: 10px;"
                           type="text"
                           class="form-control" id="email" name="email"/>
                </div>
                <button type="button" class="btn btn-default"
                        style="width: 90px;height: 25px; margin-top: 30px;margin-left: 90px;" onclick="zhuce()">注册
                </button>
                <button type="button" class="btn btn-default"
                        style="width: 100px;height: 25px; margin-top: 30px;margin-left: 90px;" onclick="window.location.href='demo/layout/loginLayout.html'">已有账号
                </button>
            </form>
        </div>
    </div>
</div>
</body>
</html>

<script>
    var httpreq=null;
    var ts = document.getElementById("ts")
    function zhuce() {
        // if(!confirm($("#zc1")[0])) return
        var zc1=new FormData($("#zc1")[0])
         var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        var password2 = document.getElementById("password2").value;
        var phone = document.getElementById("phone").value;
        var email = document.getElementById("email").value;
        if(username==""||password==""||password2==""||phone=="") {
            ts.innerHTML="用户名或密码不能为空"
            return
        }
        if(password!=password2){
            ts.innerHTML="密码不一致"
            return
        }
        $.ajax(
            {
                type:'POST',
                url:"customer/register",
                data:zc1,
                processData:false,
                contentType:false,
                success:function(result){
                    //alert(result);
                    if(result.indexOf("FaIl")!=-1){
                        ts.innerHTML="无效的用户和密码"
                    }else{
                        ts.innerHTML="注册成功，稍后带你到登录界面"
                        setTimeout("window.location.href='demo/layout/loginLayout.html',100")
                        // alert(httpreq.responseText)
                    }
                }
            }
        );

    }


</script>